#include "lolevel.h"
#include "platform.h"
#include "core.h"
#include "conf.h"

static long *nrflag = (long*)0x5828;	// ??? ROM:FFD10EE0 "ShutterSoundTask"

#include "../../../generic/capt_seq.c"

// ROM:FFC59274 task_CaptSeqTask()
void __attribute__((naked,noinline)) capt_seq_task() {
	asm volatile (
			"STMFD   SP!, {R3-R7,LR}\n"
			"LDR     R7, =0x33324\n"
			"LDR     R6, =0x26C0\n"
"loc_FFC59280:\n"
			"LDR     R0, [R6,#4]\n"
			"MOV     R2, #0\n"
			"MOV     R1, SP\n"
			"BL      sub_FFC28AA0\n"
			"TST     R0, #1\n"
			"BEQ     loc_FFC592AC\n"
			"LDR     R1, =0x5B4\n"
			"LDR     R0, =0xFFC58E80\n"
			"BL      sub_FFC0F680\n"
			"BL      sub_FFC0F438\n"
			"LDMFD   SP!, {R3-R7,PC}\n"
"loc_FFC592AC:\n"
			"LDR     R0, [SP]\n"
			"LDR     R1, [R0]\n"
			"CMP     R1, #0x1D\n"
			"ADDLS   PC, PC, R1,LSL#2\n"
			"B       loc_FFC594BC\n"
"loc_FFC592C0:\n"
			"B       loc_FFC59338\n"
"loc_FFC592C4:\n"
			"B       loc_FFC59340\n"
"loc_FFC592C8:\n"
			"B       loc_FFC59368\n"
"loc_FFC592CC:\n"
			"B       loc_FFC5937C\n"
"loc_FFC592D0:\n"
			"B       loc_FFC59374\n"
"loc_FFC592D4:\n"
			"B       loc_FFC59384\n"
"loc_FFC592D8:\n"
			"B       loc_FFC5938C\n"
"loc_FFC592DC:\n"
			"B       loc_FFC59398\n"
"loc_FFC592E0:\n"
			"B       loc_FFC593F0\n"
"loc_FFC592E4:\n"
			"B       loc_FFC5937C\n"
"loc_FFC592E8:\n"
			"B       loc_FFC593F8\n"
"loc_FFC592EC:\n"
			"B       loc_FFC59404\n"
"loc_FFC592F0:\n"
			"B       loc_FFC5940C\n"
"loc_FFC592F4:\n"
			"B       loc_FFC59414\n"
"loc_FFC592F8:\n"
			"B       loc_FFC5941C\n"
"loc_FFC592FC:\n"
			"B       loc_FFC59424\n"
"loc_FFC59300:\n"
			"B       loc_FFC5942C\n"
"loc_FFC59304:\n"
			"B       loc_FFC59434\n"
"loc_FFC59308:\n"
			"B       loc_FFC59440\n"
"loc_FFC5930C:\n"
			"B       loc_FFC59448\n"
"loc_FFC59310:\n"
			"B       loc_FFC59450\n"
"loc_FFC59314:\n"
			"B       loc_FFC59458\n"
"loc_FFC59318:\n"
			"B       loc_FFC59460\n"
"loc_FFC5931C:\n"
			"B       loc_FFC5946C\n"
"loc_FFC59320:\n"
			"B       loc_FFC59474\n"
"loc_FFC59324:\n"
			"B       loc_FFC5947C\n"
"loc_FFC59328:\n"
			"B       loc_FFC59484\n"
"loc_FFC5932C:\n"
			"B       loc_FFC5948C\n"
"loc_FFC59330:\n"
			"B       loc_FFC59498\n"
"loc_FFC59334:\n"
			"B       loc_FFC594C8\n"
"loc_FFC59338:\n"
			"BL      sub_FFC59B54\n"
			"BL      shooting_expo_param_override\n"      // +
			"B       loc_FFC59390\n"
"loc_FFC59340:\n"
			"MOV     R0, #0xC\n"
			"BL      sub_FFC5D830\n"
			"TST     R0, #1\n"
			"LDR     R0, [SP]\n"
			"MOVNE   R1, #1\n"
			"LDRNE   R2, [R0,#0xC]\n"
			"MOVNE   R0, #1\n"
			"BNE     loc_FFC593E8\n"
			"BL      sub_FFC595E8_my\n"  //--------->
			"B       loc_FFC594C8\n"
"loc_FFC59368:\n"
			"MOV     R0, #1\n"
			"BL      sub_FFC59DDC\n"
			"B       loc_FFC594C8\n"
"loc_FFC59374:\n"
			"BL      sub_FFC597C0\n"
			"B       loc_FFC594C8\n"
"loc_FFC5937C:\n"
			"BL      sub_FFC59B34\n"
			"B       loc_FFC594C8\n"
"loc_FFC59384:\n"
			"BL      sub_FFC59B3C\n"
			"B       loc_FFC594C8\n"
"loc_FFC5938C:\n"
			"BL      sub_FFC59CEC\n"
"loc_FFC59390:\n"
			"BL      sub_FFC5758C\n"
			"B       loc_FFC594C8\n"
"loc_FFC59398:\n"
			"LDR     R4, [R0,#0xC]\n"
			"BL      sub_FFC59B44\n"
			"MOV     R0, R4\n"
			"BL      sub_FFD0FE90\n"
			"TST     R0, #1\n"
			"MOV     R5, R0\n"
			"BNE     loc_FFC593D8\n"
			"BL      sub_FFC6970C\n"
			"STR     R0, [R4,#0x18]\n"
			"MOV     R0, R4\n"
			"BL      sub_FFD10E04\n"
			"MOV     R0, R4\n"
			"BL      sub_FFD111A4\n"
			"MOV     R5, R0\n"
			"LDR     R0, [R4,#0x18]\n"
			"BL      sub_FFC69944\n"
"loc_FFC593D8:\n"
			"BL      sub_FFC59B34\n"
			"MOV     R2, R4\n"
			"MOV     R1, #9\n"
			"MOV     R0, R5\n"
"loc_FFC593E8:\n"
			"BL      sub_FFC57984\n"
			"B       loc_FFC594C8\n"
"loc_FFC593F0:\n"
			"BL      sub_FFC59D54\n"
			"B       loc_FFC59390\n"
"loc_FFC593F8:\n"
			"LDR     R0, [R7,#0x4C]\n"
			"BL      sub_FFC5A0F8\n"
			"B       loc_FFC594C8\n"
"loc_FFC59404:\n"
			"BL      sub_FFC5A3A8\n"
			"B       loc_FFC594C8\n"
"loc_FFC5940C:\n"
			"BL      sub_FFC5A43C\n"
			"B       loc_FFC594C8\n"
"loc_FFC59414:\n"
			"BL      sub_FFD100BC\n"
			"B       loc_FFC594C8\n"
"loc_FFC5941C:\n"
			"BL      sub_FFD102B4\n"
			"B       loc_FFC594C8\n"
"loc_FFC59424:\n"
			"BL      sub_FFD10348\n"
			"B       loc_FFC594C8\n"
"loc_FFC5942C:\n"
			"BL      sub_FFD10408\n"
			"B       loc_FFC594C8\n"
"loc_FFC59434:\n"
			"MOV     R0, #0\n"
			"BL      sub_FFD10600\n"
			"B       loc_FFC594C8\n"
"loc_FFC59440:\n"
			"BL      sub_FFD10750\n"
			"B       loc_FFC594C8\n"
"loc_FFC59448:\n"
			"BL      sub_FFD107E0\n"
			"B       loc_FFC594C8\n"
"loc_FFC59450:\n"
			"BL      sub_FFD108A0\n"
			"B       loc_FFC594C8\n"
"loc_FFC59458:\n"
			"BL      sub_FFC59F38\n"
			"B       loc_FFC594C8\n"
"loc_FFC59460:\n"
			"BL      sub_FFC59F74\n"
			"BL      sub_FFC26C78\n"
			"B       loc_FFC594C8\n"
"loc_FFC5946C:\n"
			"BL      sub_FFD104D4\n"
			"B       loc_FFC594C8\n"
"loc_FFC59474:\n"
			"BL      sub_FFD10518\n"
			"B       loc_FFC594C8\n"
"loc_FFC5947C:\n"
			"BL      sub_FFC5C070\n"
			"B       loc_FFC594C8\n"
"loc_FFC59484:\n"
			"BL      sub_FFC5C0F0\n"
			"B       loc_FFC594C8\n"
"loc_FFC5948C:\n"
			"BL      sub_FFC5C14C\n"
			"BL      sub_FFC5C10C\n"
			"B       loc_FFC594C8\n"
"loc_FFC59498:\n"
			"LDRH    R0, [R7,#0x8C]\n"
			"CMP     R0, #4\n"
			"LDRNEH  R0, [R7]\n"
			"SUBNE   R12, R0, #0x8200\n"
			"SUBNES  R12, R12, #0x2A\n"
			"BNE     loc_FFC594C8\n"
			"BL      sub_FFC5C0F0\n"
			"BL      sub_FFC5C490\n"
			"B       loc_FFC594C8\n"
"loc_FFC594BC:\n"
			"LDR     R1, =0x70B\n"
			"LDR     R0, =0xFFC58E80\n"
			"BL      sub_FFC0F680\n"
"loc_FFC594C8:\n"
			"LDR     R0, [SP]\n"
			"LDR     R1, [R0,#4]\n"
			"LDR     R0, [R6]\n"
			"BL      sub_FFC28810\n"
			"LDR     R4, [SP]\n"
			"LDR     R0, [R4,#8]\n"
			"CMP     R0, #0\n"
			"LDREQ   R1, =0x132\n"
			"LDREQ   R0, =0xFFC58E80\n"
			"BLEQ    sub_FFC0F680\n"
			"MOV     R0, #0\n"
			"STR     R0, [R4,#8]\n"
			"B       loc_FFC59280\n"
	);
} 



void __attribute__((naked,noinline)) sub_FFC595E8_my(){ // 
	asm volatile(
			"STMFD   SP!, {R3-R5,LR}\n"
			"LDR     R4, [R0,#0xC]\n"
			"LDR     R0, [R4,#8]\n"
			"ORR     R0, R0, #1\n"
			"STR     R0, [R4,#8]\n"
			"BL      sub_FFC59B44\n"
			"MOV     R0, R4\n"
			"BL      sub_FFC59EEC\n"
			"MOV     R0, R4\n"
			"BL      sub_FFD0FAFC\n"
			"CMP     R0, #0\n"
			"MOV     R0, R4\n"
			"BEQ     loc_FFC59638\n"
			"BL      sub_FFD0FB88\n"
			"TST     R0, #1\n"
			"MOVNE   R2, R4\n"
			"LDMNEFD SP!, {R3-R5,LR}\n"
			"MOVNE   R1, #1\n"
			"BNE     sub_FFC57984\n"
			"B       loc_FFC5963C\n"
"loc_FFC59638:\n"
			"BL      sub_FFD0FB4C\n"
"loc_FFC5963C:\n"
			"MOV     R0, #0\n"
			"STR     R0, [SP]\n"
			"LDR     R0, =0x33324\n"
			"MOV     R2, #2\n"
			"LDRH    R0, [R0,#0x8A]\n"
			"MOV     R1, SP\n"
			"CMP     R0, #3\n"
			"LDRNE   R0, [R4,#0xC]\n"
			"CMPNE   R0, #1\n"
			"MOVHI   R0, #1\n"
			"STRHI   R0, [SP]\n"
			"LDR     R0, =0x127\n"
			"BL      sub_FFC6944C\n"
			"BL      sub_FFD2F710\n"
			"BL      sub_FFC6970C\n"
			"STR     R0, [R4,#0x18]\n"
			"MOV     R0, R4\n"
			"BL      sub_FFD10E04\n"
			"BL      sub_FFD11820\n"
			"MOV     R0, R4\n"
			"BL      sub_FFD10ECC_my\n"			//---------->
			"MOV     R5, R0\n"
			"BL      capt_seq_hook_raw_here\n"	// +
			"BL      sub_FFC5C0F0\n"
			"BL      sub_FFC5C138\n"
			"BL      sub_FFC5C178\n"
			"MOV     R2, R4\n"
			"MOV     R1, #1\n"
			"MOV     R0, R5\n"
			"BL      sub_FFC57984\n"
			"BL      sub_FFD11158\n"
			"CMP     R0, #0\n"
			"LDRNE   R0, [R4,#8]\n"
			"ORRNE   R0, R0, #0x2000\n"
			"STRNE   R0, [R4,#8]\n"
			"LDMFD   SP!, {R3-R5,PC}\n"
	);
}

void __attribute__((naked,noinline)) sub_FFD10ECC_my(){ // 
	asm volatile(
			"STMFD   SP!, {R0-R8,LR}\n"
			"MOV     R4, R0\n"
			"BL      sub_FFD119B4\n"
			"MOV     R1, #0xFFFFFFFF\n"
			"BL      sub_FFC28844\n"
			"LDR     R5, =0x5828\n"
			"LDR     R0, [R5,#0xC]\n"
			"CMP     R0, #0\n"
			"BNE     loc_FFD10F1C\n"
			"MOV     R1, #1\n"
			"MOV     R0, #0\n"
			"BL      sub_FFC0F4B4\n"
			"STR     R0, [R5,#0xC]\n"
			"MOV     R3, #0\n"
			"STR     R3, [SP]\n"
			"LDR     R3, =0xFFD10990\n"
			"LDR     R0, =0xFFD11128\n"
			"MOV     R2, #0x400\n"
			"MOV     R1, #0x17\n"
			"BL      sub_FFC0F480\n"
"loc_FFD10F1C:\n"
			"MOV     R2, #4\n"
			"ADD     R1, SP, #8\n"
			"MOV     R0, #0x8A\n"
			"BL      sub_FFC6957C\n"
			"TST     R0, #1\n"
			"LDRNE   R1, =0x3BA\n"
			"LDRNE   R0, =0xFFD10BBC\n"
			"BLNE    sub_FFC0F680\n"
			"LDR     R6, =0x333E0\n"
			"LDR     R7, =0x33324\n"
			"LDR     R3, [R6]\n"
			"LDRSH   R2, [R6,#0xC]\n"
			"LDRSH   R1, [R6,#0xE]\n"
			"LDR     R0, [R7,#0x80]\n"
		//	"BL      nullsub_56\n"
			"BL      sub_FFC455A8\n"
			"LDR     R3, =0x5830\n"
			"STRH    R0, [R4,#0xA4]\n"
			"SUB     R2, R3, #4\n"
			"STRD    R2, [SP]\n"
			"MOV     R1, R0\n"
			"LDRH    R0, [R7,#0x54]\n"
			"LDRSH   R2, [R6,#0xC]\n"
			"SUB     R3, R3, #8\n"
			"BL      sub_FFD12020\n"
			"BL      wait_until_remote_button_is_released\n"     // +
			"BL      capt_seq_hook_set_nr\n"                     // +
			"B       sub_FFD10F80\n"                             // continue function in firmware
	);
}


/*************************************************************/

// ROM:FFC91654 task_ExpDrvTask
void __attribute__((naked,noinline)) exp_drv_task(){
	asm volatile(
			"STMFD   SP!, {R4-R8,LR}\n"
			"SUB     SP, SP, #0x20\n"
			"LDR     R8, =0xBB8\n"
			"LDR     R7, =0x38CC\n"
			"LDR     R5, =0x3C714\n"
			"MOV     R0, #0\n"
			"ADD     R6, SP, #0x10\n"
			"STR     R0, [SP,#0xC]\n"
"loc_FFC91674:\n"
			"LDR     R0, [R7,#0x20]\n"
			"MOV     R2, #0\n"
			"ADD     R1, SP, #0x1C\n"
			"BL      sub_FFC28AA0\n"
			"LDR     R0, [SP,#0xC]\n"
			"CMP     R0, #1\n"
			"BNE     loc_FFC916C0\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R0, [R0]\n"
			"CMP     R0, #0x13\n"
			"CMPNE   R0, #0x14\n"
			"CMPNE   R0, #0x15\n"
			"CMPNE   R0, #0x16\n"
			"BEQ     loc_FFC91824\n"
			"CMP     R0, #0x28\n"
			"BEQ     loc_FFC917AC\n"
			"ADD     R1, SP, #0xC\n"
			"MOV     R0, #0\n"
			"BL      sub_FFC91604\n"
"loc_FFC916C0:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R1, [R0]\n"
			"CMP     R1, #0x2E\n"
			"BNE     loc_FFC916F0\n"
			"LDR     R0, [SP,#0x1C]\n"
			"BL      sub_FFC9295C\n"
			"LDR     R0, [R7,#0x1C]\n"
			"MOV     R1, #1\n"
			"BL      sub_FFC28810\n"
			"BL      sub_FFC0F438\n"
			"ADD     SP, SP, #0x20\n"
			"LDMFD   SP!, {R4-R8,PC}\n"
"loc_FFC916F0:\n"
			"CMP     R1, #0x2D\n"
			"BNE     loc_FFC9170C\n"
			"LDR     R2, [R0,#0x8C]!\n"
			"LDR     R1, [R0,#4]\n"
			"MOV     R0, R1\n"
			"BLX     R2\n"
			"B       loc_FFC91C4C\n"
"loc_FFC9170C:\n"
			"CMP     R1, #0x26\n"
			"BNE     loc_FFC9175C\n"
			"LDR     R0, [R7,#0x1C]\n"
			"MOV     R1, #0x80\n"
			"BL      sub_FFC28844\n"
			"LDR     R0, =0xFFC8DDD0\n"
			"MOV     R1, #0x80\n"
			"BL      sub_FFD085BC\n"
			"LDR     R0, [R7,#0x1C]\n"
			"MOV     R2, R8\n"
			"MOV     R1, #0x80\n"
			"BL      sub_FFC28750\n"
			"TST     R0, #1\n"
			"LDRNE   R1, =0xE5F\n"
			"BNE     loc_FFC91818\n"
"loc_FFC91748:\n"
			"LDR     R1, [SP,#0x1C]\n"
			"LDR     R0, [R1,#0x90]\n"
			"LDR     R1, [R1,#0x8C]\n"
			"BLX     R1\n"
			"B       loc_FFC91C4C\n"
"loc_FFC9175C:\n"
			"CMP     R1, #0x27\n"
			"BNE     loc_FFC917A4\n"
			"ADD     R1, SP, #0xC\n"
			"BL      sub_FFC91604\n"
			"LDR     R0, [R7,#0x1C]\n"
			"MOV     R1, #0x100\n"
			"BL      sub_FFC28844\n"
			"LDR     R0, =0xFFC8DDE0\n"
			"MOV     R1, #0x100\n"
			"BL      sub_FFD08844\n"
			"LDR     R0, [R7,#0x1C]\n"
			"MOV     R2, R8\n"
			"MOV     R1, #0x100\n"
			"BL      sub_FFC28750\n"
			"TST     R0, #1\n"
			"BEQ     loc_FFC91748\n"
			"LDR     R1, =0xE69\n"
			"B       loc_FFC91818\n"
"loc_FFC917A4:\n"
			"CMP     R1, #0x28\n"
			"BNE     loc_FFC917BC\n"
"loc_FFC917AC:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"ADD     R1, SP, #0xC\n"
			"BL      sub_FFC91604\n"
			"B       loc_FFC91748\n"
"loc_FFC917BC:\n"
			"CMP     R1, #0x2B\n"
			"BNE     loc_FFC917D4\n"
			"BL      sub_FFC811DC\n"
			"BL      sub_FFC81E04\n"
			"BL      sub_FFC81954\n"
			"B       loc_FFC91748\n"
"loc_FFC917D4:\n"
			"CMP     R1, #0x2C\n"
			"BNE     loc_FFC91824\n"
			"LDR     R0, [R7,#0x1C]\n"
			"MOV     R1, #4\n"
			"BL      sub_FFC28844\n"
			"LDR     R1, =0xFFC8DE00\n"
			"LDR     R0, =0xFFFFF400\n"
			"MOV     R2, #4\n"
			"BL      sub_FFC80C58\n"
			"BL      sub_FFC80EE0\n"
			"LDR     R0, [R7,#0x1C]\n"
			"MOV     R2, R8\n"
			"MOV     R1, #4\n"
			"BL      sub_FFC2866C\n"
			"TST     R0, #1\n"
			"BEQ     loc_FFC91748\n"
			"LDR     R1, =0xE91\n"
"loc_FFC91818:\n"
			"LDR     R0, =0xFFC8E440\n"
			"BL      sub_FFC0F680\n"
			"B       loc_FFC91748\n"
"loc_FFC91824:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"MOV     R4, #1\n"
			"LDR     R1, [R0]\n"
			"CMP     R1, #0x11\n"
			"CMPNE   R1, #0x12\n"
			"BNE     sub_FFC91894\n"
			"LDR     R1, [R0,#0x7C]\n"
			"ADD     R1, R1, R1,LSL#1\n"
			"ADD     R1, R0, R1,LSL#2\n"
			"SUB     R1, R1, #8\n"
			"LDMIA   R1, {R2-R4}\n"
			"STMIA   R6, {R2-R4}\n"
		//	"BL      loc_FFC8FF90\n"
			"BL      sub_FFC8FF90\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R1, [R0,#0x7C]\n"
			"LDR     R3, [R0,#0x8C]\n"
			"LDR     R2, [R0,#0x90]\n"
			"ADD     R0, R0, #4\n"
			"BLX     R3\n"
			"LDR     R0, [SP,#0x1C]\n"
			"BL      sub_FFC92D24\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R1, [R0,#0x7C]\n"
			"LDR     R3, [R0,#0x94]\n"
			"LDR     R2, [R0,#0x98]\n"
			"ADD     R0, R0, #4\n"
			"BLX     R3\n"
			"B       loc_FFC91B8C\n"
"loc_FFC91894:\n"
			"CMP     R1, #0x13\n"
			"CMPNE   R1, #0x14\n"
			"CMPNE   R1, #0x15\n"
			"CMPNE   R1, #0x16\n"
			"BNE     loc_FFC9194C\n"
			"ADD     R3, SP, #0xC\n"
			"MOV     R2, SP\n"
			"ADD     R1, SP, #0x10\n"
			"BL      sub_FFC9026C\n"
			"CMP     R0, #1\n"
			"MOV     R4, R0\n"
			"CMPNE   R4, #5\n"
			"BNE     loc_FFC918E8\n"
			"LDR     R0, [SP,#0x1C]\n"
			"MOV     R2, R4\n"
			"LDR     R1, [R0,#0x7C]!\n"
			"LDR     R12, [R0,#0x10]!\n"
			"LDR     R3, [R0,#4]\n"
			"MOV     R0, SP\n"
			"BLX     R12\n"
			"B       loc_FFC91920\n"
"loc_FFC918E8:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"CMP     R4, #2\n"
			"LDR     R3, [R0,#0x90]\n"
			"CMPNE   R4, #6\n"
			"BNE     loc_FFC91934\n"
			"LDR     R12, [R0,#0x8C]\n"
			"MOV     R0, SP\n"
			"MOV     R2, R4\n"
			"MOV     R1, #1\n"
			"BLX     R12\n"
			"LDR     R0, [SP,#0x1C]\n"
			"MOV     R2, SP\n"
			"ADD     R1, SP, #0x10\n"
			"BL      sub_FFC9130C\n"
"loc_FFC91920:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R2, [SP,#0xC]\n"
			"MOV     R1, R4\n"
			"BL      sub_FFC915A4\n"
			"B       loc_FFC91B8C\n"
"loc_FFC91934:\n"
			"LDR     R1, [R0,#0x7C]\n"
			"LDR     R12, [R0,#0x8C]\n"
			"ADD     R0, R0, #4\n"
			"MOV     R2, R4\n"
			"BLX     R12\n"
			"B       loc_FFC91B8C\n"
"loc_FFC9194C:\n"
			"CMP     R1, #0x22\n"
			"CMPNE   R1, #0x23\n"
			"BNE     loc_FFC91998\n"
			"LDR     R1, [R0,#0x7C]\n"
			"ADD     R1, R1, R1,LSL#1\n"
			"ADD     R1, R0, R1,LSL#2\n"
			"SUB     R1, R1, #8\n"
			"LDMIA   R1, {R2-R4}\n"
			"STMIA   R6, {R2-R4}\n"
			"BL      sub_FFC8F4E0\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R1, [R0,#0x7C]\n"
			"LDR     R3, [R0,#0x8C]\n"
			"LDR     R2, [R0,#0x90]\n"
			"ADD     R0, R0, #4\n"
			"BLX     R3\n"
			"LDR     R0, [SP,#0x1C]\n"
			"BL      sub_FFC8F7D4\n"
			"B       loc_FFC91B8C\n"
"loc_FFC91998:\n"
			"ADD     R1, R0, #4\n"
			"LDMIA   R1, {R2,R3,R12}\n"
			"STMIA   R6, {R2,R3,R12}\n"
			"LDR     R1, [R0]\n"
			"CMP     R1, #0x25\n"
			"ADDLS   PC, PC, R1,LSL#2\n"
			"B       loc_FFC91B6C\n"
"loc_FFC919B4:\n"
			"B       loc_FFC91A4C\n"
"loc_FFC919B8:\n"
			"B       loc_FFC91A4C\n"
"loc_FFC919BC:\n"
			"B       loc_FFC91A54\n"
"loc_FFC919C0:\n"
			"B       loc_FFC91A5C\n"
"loc_FFC919C4:\n"
			"B       loc_FFC91A5C\n"
"loc_FFC919C8:\n"
			"B       loc_FFC91A5C\n"
"loc_FFC919CC:\n"
			"B       loc_FFC91A4C\n"
"loc_FFC919D0:\n"
			"B       loc_FFC91A54\n"
"loc_FFC919D4:\n"
			"B       loc_FFC91A5C\n"
"loc_FFC919D8:\n"
			"B       loc_FFC91A5C\n"
"loc_FFC919DC:\n"
			"B       loc_FFC91A74\n"
"loc_FFC919E0:\n"
			"B       loc_FFC91A74\n"
"loc_FFC919E4:\n"
			"B       loc_FFC91B60\n"
"loc_FFC919E8:\n"
			"B       loc_FFC91B68\n"
"loc_FFC919EC:\n"
			"B       loc_FFC91B68\n"
"loc_FFC919F0:\n"
			"B       loc_FFC91B68\n"
"loc_FFC919F4:\n"
			"B       loc_FFC91B68\n"
"loc_FFC919F8:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC919FC:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A00:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A04:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A08:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A0C:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A10:\n"
			"B       loc_FFC91A64\n"
"loc_FFC91A14:\n"
			"B       loc_FFC91A6C\n"
"loc_FFC91A18:\n"
			"B       loc_FFC91A6C\n"
"loc_FFC91A1C:\n"
			"B       loc_FFC91A80\n"
"loc_FFC91A20:\n"
			"B       loc_FFC91A80\n"
"loc_FFC91A24:\n"
			"B       loc_FFC91A88\n"
"loc_FFC91A28:\n"
			"B       loc_FFC91AB8\n"
"loc_FFC91A2C:\n"
			"B       loc_FFC91AE8\n"
"loc_FFC91A30:\n"
			"B       loc_FFC91B18\n"
"loc_FFC91A34:\n"
			"B       loc_FFC91B48\n"
"loc_FFC91A38:\n"
			"B       loc_FFC91B48\n"
"loc_FFC91A3C:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A40:\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A44:\n"
			"B       loc_FFC91B50\n"
"loc_FFC91A48:\n"
			"B       loc_FFC91B58\n"
"loc_FFC91A4C:\n"
			"BL      sub_FFC8E2E8\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A54:\n"
			"BL      sub_FFC8E56C\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A5C:\n"
			"BL      sub_FFC8E774\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A64:\n"
			"BL      sub_FFC8E9EC\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A6C:\n"
			"BL      sub_FFC8EBE4\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A74:\n"
			"BL      sub_FFC8EEA0_my\n"		//---------->
			"MOV     R4, #0\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A80:\n"
			"BL      sub_FFC8EFE0\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91A88:\n"
			"LDRH    R1, [R0,#4]\n"
			"STRH    R1, [SP,#0x10]\n"
			"LDRH    R1, [R5,#2]\n"
			"STRH    R1, [SP,#0x12]\n"
			"LDRH    R1, [R5,#4]\n"
			"STRH    R1, [SP,#0x14]\n"
			"LDRH    R1, [R5,#6]\n"
			"STRH    R1, [SP,#0x16]\n"
			"LDRH    R1, [R0,#0xC]\n"
			"STRH    R1, [SP,#0x18]\n"
			"BL      sub_FFC929D0\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91AB8:\n"
			"LDRH    R1, [R0,#4]\n"
			"STRH    R1, [SP,#0x10]\n"
			"LDRH    R1, [R5,#2]\n"
			"STRH    R1, [SP,#0x12]\n"
			"LDRH    R1, [R5,#4]\n"
			"STRH    R1, [SP,#0x14]\n"
			"LDRH    R1, [R5,#6]\n"
			"STRH    R1, [SP,#0x16]\n"
			"LDRH    R1, [R5,#8]\n"
			"STRH    R1, [SP,#0x18]\n"
			"BL      sub_FFC92B3C\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91AE8:\n"
			"LDRH    R1, [R5]\n"
			"STRH    R1, [SP,#0x10]\n"
			"LDRH    R1, [R0,#6]\n"
			"STRH    R1, [SP,#0x12]\n"
			"LDRH    R1, [R5,#4]\n"
			"STRH    R1, [SP,#0x14]\n"
			"LDRH    R1, [R5,#6]\n"
			"STRH    R1, [SP,#0x16]\n"
			"LDRH    R1, [R5,#8]\n"
			"STRH    R1, [SP,#0x18]\n"
			"BL      sub_FFC92BE8\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91B18:\n"
			"LDRH    R1, [R5]\n"
			"STRH    R1, [SP,#0x10]\n"
			"LDRH    R1, [R5,#2]\n"
			"STRH    R1, [SP,#0x12]\n"
			"LDRH    R1, [R5,#4]\n"
			"STRH    R1, [SP,#0x14]\n"
			"LDRH    R1, [R5,#6]\n"
			"STRH    R1, [SP,#0x16]\n"
			"LDRH    R1, [R0,#0xC]\n"
			"STRH    R1, [SP,#0x18]\n"
			"BL      sub_FFC92C88\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91B48:\n"
			"BL      sub_FFC8F338\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91B50:\n"
			"BL      sub_FFC8F8D8\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91B58:\n"
			"BL      sub_FFC8FB14\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91B60:\n"
			"BL      sub_FFC8FC90\n"
			"B       loc_FFC91B6C\n"
"loc_FFC91B68:\n"
			"BL      sub_FFC8FE2C\n"
"loc_FFC91B6C:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R1, [R0,#0x7C]\n"
			"LDR     R3, [R0,#0x8C]\n"
			"LDR     R2, [R0,#0x90]\n"
			"ADD     R0, R0, #4\n"
			"BLX     R3\n"
			"CMP     R4, #1\n"
			"BNE     loc_FFC91BD4\n"
"loc_FFC91B8C:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"MOV     R2, #0xC\n"
			"LDR     R1, [R0,#0x7C]\n"
			"ADD     R1, R1, R1,LSL#1\n"
			"ADD     R0, R0, R1,LSL#2\n"
			"SUB     R4, R0, #8\n"
			"LDR     R0, =0x3C714\n"
			"ADD     R1, SP, #0x10\n"
			"BL      sub_FFE80E24\n"
			"LDR     R0, =0x3C720\n"
			"MOV     R2, #0xC\n"
			"ADD     R1, SP, #0x10\n"
			"BL      sub_FFE80E24\n"
			"LDR     R0, =0x3C72C\n"
			"MOV     R2, #0xC\n"
			"MOV     R1, R4\n"
			"BL      sub_FFE80E24\n"
			"B       loc_FFC91C4C\n"
"loc_FFC91BD4:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"LDR     R0, [R0]\n"
			"CMP     R0, #0xB\n"
			"BNE     loc_FFC91C1C\n"
			"MOV     R3, #0\n"
			"STR     R3, [SP]\n"
			"MOV     R3, #1\n"
			"MOV     R2, #1\n"
			"MOV     R1, #1\n"
			"MOV     R0, #0\n"
			"BL      sub_FFC8E0F0\n"
			"MOV     R3, #0\n"
			"STR     R3, [SP]\n"
			"MOV     R3, #1\n"
			"MOV     R2, #1\n"
			"MOV     R1, #1\n"
			"MOV     R0, #0\n"
			"B       loc_FFC91C48\n"
"loc_FFC91C1C:\n"
			"MOV     R3, #1\n"
			"MOV     R2, #1\n"
			"MOV     R1, #1\n"
			"MOV     R0, #1\n"
			"STR     R3, [SP]\n"
			"BL      sub_FFC8E0F0\n"
			"MOV     R3, #1\n"
			"MOV     R2, #1\n"
			"MOV     R1, #1\n"
			"MOV     R0, #1\n"
			"STR     R3, [SP]\n"
"loc_FFC91C48:\n"
			"BL      sub_FFC8E230\n"
"loc_FFC91C4C:\n"
			"LDR     R0, [SP,#0x1C]\n"
			"BL      sub_FFC9295C\n"
			"B       loc_FFC91674\n"
	);
}

void __attribute__((naked,noinline)) sub_FFC8EEA0_my(){ // 
	asm volatile(
		 "STMFD   SP!, {R4-R8,LR}\n"
		"LDR     R7, =0x38CC\n"
		"MOV     R4, R0\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R1, #0x3E\n"
		"BL      sub_FFC28844\n"
		"LDRSH   R0, [R4,#4]\n"
		"MOV     R2, #0\n"
		"MOV     R1, #0\n"
		"BL      sub_FFC8DE54\n"
		"MOV     R6, R0\n"
		"LDRSH   R0, [R4,#6]\n"
		"BL      sub_FFC8DF64\n"
		"LDRSH   R0, [R4,#8]\n"
		"BL      sub_FFC8DFBC\n"
		"LDRSH   R0, [R4,#0xA]\n"
		"BL      sub_FFC8E014\n"
		"LDRSH   R0, [R4,#0xC]\n"
		"MOV     R1, #0\n"
		"BL      sub_FFC8E06C\n"
		"MOV     R5, R0\n"
		"LDR     R0, [R4]\n"
		"LDR     R8, =0x3C72C\n"
		"CMP     R0, #0xB\n"
		"MOVEQ   R6, #0\n"
		"MOVEQ   R5, #0\n"
		"BEQ     loc_FFC8EF34\n"
		"CMP     R6, #1\n"
		"BNE     loc_FFC8EF34\n"
		"LDRSH   R0, [R4,#4]\n"
		"LDR     R1, =0xFFC8DDC0\n"
		"MOV     R2, #2\n"
		"BL      sub_FFD08710\n"
		"STRH    R0, [R4,#4]\n"
		"MOV     R0, #0\n"
		"STR     R0, [R7,#0x28]\n"
		"B       loc_FFC8EF3C\n"
"loc_FFC8EF34:\n"
		"LDRH    R0, [R8]\n"
		"STRH    R0, [R4,#4]\n"
"loc_FFC8EF3C:\n"
		"CMP     R5, #1\n"
		"LDRNEH  R0, [R8,#8]\n"
		"BNE     loc_FFC8EF58\n"
		"LDRSH   R0, [R4,#0xC]\n"
		"LDR     R1, =0xFFC8DE44\n"
		"MOV     R2, #0x20\n"
		"BL      sub_FFC9298C\n"
"loc_FFC8EF58:\n"
		"STRH    R0, [R4,#0xC]\n"
		"LDRSH   R0, [R4,#6]\n"
		"BL      sub_FFC80F4C_my\n"		//----------->
		"LDRSH   R0, [R4,#8]\n"
		"MOV     R1, #1\n"
		"BL      sub_FFC8169C\n"
		"MOV     R1, #0\n"
		"ADD     R0, R4, #8\n"
		"BL      sub_FFC81724\n"
		"LDRSH   R0, [R4,#0xE]\n"
		"BL      sub_FFC8914C\n"
		"LDR     R4, =0xBB8\n"
		"CMP     R6, #1\n"
		"BNE     loc_FFC8EFB0\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R2, R4\n"
		"MOV     R1, #2\n"
		"BL      sub_FFC28750\n"
		"TST     R0, #1\n"
		"LDRNE   R1, =0x5A3\n"
		"LDRNE   R0, =0xFFC8E440\n"
		"BLNE    sub_FFC0F680\n"
"loc_FFC8EFB0:\n"
		"CMP     R5, #1\n"
		"LDMNEFD SP!, {R4-R8,PC}\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R2, R4\n"
		"MOV     R1, #0x20\n"
		"BL      sub_FFC28750\n"
		"TST     R0, #1\n"
		"LDRNE   R1, =0x5A8\n"
		"LDRNE   R0, =0xFFC8E440\n"
		"LDMNEFD SP!, {R4-R8,LR}\n"
		"BNE     sub_FFC0F680\n"
		"LDMFD   SP!, {R4-R8,PC}\n"
	);
}

void __attribute__((naked,noinline)) sub_FFC80F4C_my(){ // 
	asm volatile(
			"STMFD   SP!, {R4-R6,LR}\n"
			"LDR     R5, =0x35C0\n"
			"MOV     R4, R0\n"
			"LDR     R0, [R5,#4]\n"
			"CMP     R0, #1\n"
			"LDRNE   R1, =0x146\n"
			"LDRNE   R0, =0xFFC80D50\n"
			"BLNE    sub_FFC0F680\n"
			"CMN     R4, #0xC00\n"
			"LDREQSH R4, [R5,#2]\n"
			"CMN     R4, #0xC00\n"
			"MOVEQ   R1, #0x14C\n"
			"LDREQ   R0, =0xFFC80D50\n"
			"STRH    R4, [R5,#2]\n"
			"BLEQ    sub_FFC0F680\n"
			"MOV     R0, R4\n"
		//  "BL      _sub_FFD7D8F8\n"		// -
			"BL      apex2us\n"				// +
			"MOV     R4, R0\n"
		//	"BL      nullsub_39\n"
			"MOV     R0, R4\n"
			"BL      sub_FFCB8140\n"
			"TST     R0, #1\n"
			"LDRNE   R1, =0x151\n"
			"LDMNEFD SP!, {R4-R6,LR}\n"
			"LDRNE   R0, =0xFFC80D50\n"
			"BNE     sub_FFC0F680\n"
			"LDMFD   SP!, {R4-R6,PC}\n"
	);
}
